/*
* Static Function
*/
if(!(window.console&&console.log)){(function(){var d=function(){};var b=["assert","clear","count","debug","dir","dirxml","error","exception","group","groupCollapsed","groupEnd","info","log","markTimeline","profile","profileEnd","markTimeline","table","time","timeEnd","timeStamp","trace","warn"];var c=b.length;var a=window.console={};while(c--){a[b[c]]=d;}}());}


/*DropDownMenu By Mean @ IReallyHost.com*/

(function($) {

$.fn.DropDownMenu = function (){

	var delayTimer = "";
	var closeDelay = 500;
	//var parent = $(':has(li,ul.menu) > a',this);


	$.each($('ul.menu li.parent',this), function(i,val){
		$(this)
		.bind("mouseover",handleHover)
		.bind("mouseleave",handleHover);
	});

	function handleHover(e){

			var _curSub = $('ul.subList',this);

			if ( e.type == 'mouseover' )
			{
				$(this).addClass('tabActive');
				$('a:first',this).addClass('tabActive');

				if( _curSub.css('display') == 'none' )
				{
					$('ul.subList').hide();
					_curSub.show();
				}
			}
			else
			{
				$('ul.subList').hide();
				$(this).removeClass('tabActive');
				$('a:first',this).removeClass('tabActive');
			}
	}

	return this;
};

jQuery.fn.slideLeftHide = function(speed, callback) {
  this.animate({
    width: "hide",
    paddingLeft: "hide",
    paddingRight: "hide",
    marginLeft: "hide",
    marginRight: "hide"
  }, speed, callback);
}


$.extend({
	SideBarMenuCtrl : function(){
		$('#sidebar ul.menu li strong').click(function(){
			$('#sidebar ul.menu li ul').hide();
			$(this).next('ul').fadeIn('fast');
		});
	}

	// SlideLogo : function(){
		// var interval,currentImg=1,activeContainer, animating = false, ImgLoader = [] ;
		// var options = {
			// class_background : '#header .logo',
			// slideshowSpeed : 8000
		// };
		// var img_src = [
			// ['/template/images/logo/irh_head_2012.gif','ไอเรียลลี่โฮส','http://www.ireallyhost.com'],
			// //['/template/images/logo/irh-logo-domain-name.gif','โปรโมทชั่นจดโดเมน','http://www.ireallyhost.com/domain/'],
			// ['/template/images/slide/slide-2014-hosting.gif','เว็บโฮสติ้ง ฟรีโดเมน','http://www.ireallyhost.com/hosting/'],
			// ['/template/images/logo/slide-2014-domain.gif','จดโดเมน','http://www.ireallyhost.com/domain/'],

			// ['/template/images/logo/irh-logo-readyweb.gif','เว็บสำเร็จรูป','http://www.ireallyhost.com/readyweb/'],
			// ['/template/images/logo/irh-logo-vps.gif','VPS Server','http://www.ireallyhost.com/vps/']
		// ];

		// var navigate = function(direction) {
			// if(animating) 	return;

			// if(direction == "next")
			// {
				// currentImg++;
				// if( currentImg > img_src.length  ) {
					// currentImg = 1;
				// }
			// }
			// /*else {
				// currentImg--;
				// if(currentImg == 0) {
					// currentImg = img_src.length;
				// }
			// }*/

			// /*var currentContainer = activeContainer;
			// activeContainer = (activeContainer == 1) ? 2 : 1;*/
			// showImage(img_src[currentImg - 1],  activeContainer);
		// };

		// var checkmouseHover = 0;
		// $( options.class_background )
		// .mouseover(function() {
			// checkmouseHover = 1;
		// }).mouseout(function(){
			// checkmouseHover = 0;
		// });

		// var currentZindex = -1;
		// var showImage = function(photoObject,  activeContainer) {

			// if ( checkmouseHover == 1 ) return ;

			// animating = true;

			// currentZindex--;

			// $( options.class_background )
			// .attr('title', photoObject[1])
			// .attr('onclick',"window.location.href='" +photoObject[2] +"'" )
			// .css({
				// "background-image" : "url(" + photoObject[0] + ")",
				// 'display':'block'
			// }).hide().fadeIn();

			// animating = false;
			// /*$( options.class_background ).fadeOut(function() {
				// setTimeout(function() {
					// animating = false;
				// }, 500);
			// });*/
		// };

		// //start slide
		// navigate("next");

		// interval = setInterval(function() {
			// navigate("next");
		// }, options.slideshowSpeed );
	// }

});



$.fn.BoxSlide = function(){
	var e = this;
	var cur;
	$('div.boxS-menu > a > span', e).hover(function(){
		$('div.boxS-menu > a > span',e).removeClass('active');
		$(this).addClass('active');

		var sel = $(this).parent('a').attr('ref');
		if ( sel == cur ) return;
		cur = sel;
		$('div.boxS-content > div.boxDiv').hide();
		$('div.boxS-content #' + cur).fadeIn('fast');
	});

};



})(jQuery);




/*
 * Basic jQuery Slider plug-in v.1.3
 *
 * http://www.basic-slider.com
 *
 * Authored by John Cobb
 * http://www.johncobb.name
 * @john0514
 *
 * Copyright 2011, John Cobb
 * License: GNU General Public License, version 3 (GPL-3.0)
 * http://www.opensource.org/licenses/gpl-3.0.html
 *
 */
 (function(e){"use strict";e.fn.bjqs=function(t){var n={width:700,height:300,animtype:"fade",animduration:450,animspeed:4e3,automatic:!0,showcontrols:!0,centercontrols:!0,nexttext:"Next",prevtext:"Prev",showmarkers:!0,centermarkers:!0,keyboardnav:!0,hoverpause:!0,usecaptions:!0,randomstart:!1,responsive:!1},r=e.extend({},n,t),i=this,s=i.find("ul.bjqs"),o=s.children("li"),u=null,a=null,f=null,l=null,c=null,h=null,p=null,d=null,v={slidecount:o.length,animating:!1,paused:!1,currentslide:1,nextslide:0,currentindex:0,nextindex:0,interval:null},m={width:null,height:null,ratio:null},g={fwd:"forward",prev:"previous"},y=function(){o.addClass("bjqs-slide");r.responsive?b():E();if(v.slidecount>1){r.randomstart&&L();r.showcontrols&&x();r.showmarkers&&T();r.keyboardnav&&N();r.hoverpause&&r.automatic&&C();r.animtype==="slide"&&S()}r.usecaptions&&k();if(r.animtype==="slide"&&!r.randomstart){v.currentindex=1;v.currentslide=2}s.show();o.eq(v.currentindex).show();r.automatic&&(v.interval=setInterval(function(){O(g.fwd,!1)},r.animspeed))},b=function(){m.width=i.outerWidth();m.ratio=m.width/r.width,m.height=r.height*m.ratio;if(r.animtype==="fade"){o.css({height:r.height,width:"100%"});o.children("img").css({height:r.height,width:"100%"});s.css({height:r.height,width:"100%"});i.css({height:r.height,"max-width":r.width,position:"relative"});if(m.width<r.width){o.css({height:m.height});o.children("img").css({height:m.height});s.css({height:m.height});i.css({height:m.height})}e(window).resize(function(){m.width=i.outerWidth();m.ratio=m.width/r.width,m.height=r.height*m.ratio;o.css({height:m.height});o.children("img").css({height:m.height});s.css({height:m.height});i.css({height:m.height})})}if(r.animtype==="slide"){o.css({height:r.height,width:r.width});o.children("img").css({height:r.height,width:r.width});s.css({height:r.height,width:r.width*r.slidecount});i.css({height:r.height,"max-width":r.width,position:"relative"});if(m.width<r.width){o.css({height:m.height});o.children("img").css({height:m.height});s.css({height:m.height});i.css({height:m.height})}e(window).resize(function(){m.width=i.outerWidth(),m.ratio=m.width/r.width,m.height=r.height*m.ratio;o.css({height:m.height,width:m.width});o.children("img").css({height:m.height,width:m.width});s.css({height:m.height,width:m.width*r.slidecount});i.css({height:m.height});h.css({height:m.height,width:m.width});w(function(){O(!1,v.currentslide)},200,"some unique string")})}},w=function(){var e={};return function(t,n,r){r||(r="Don't call this twice without a uniqueId");e[r]&&clearTimeout(e[r]);e[r]=setTimeout(t,n)}}(),E=function(){o.css({height:r.height,width:r.width});s.css({height:r.height,width:r.width});i.css({height:r.height,width:r.width,position:"relative"})},S=function(){p=o.eq(0).clone();d=o.eq(v.slidecount-1).clone();p.attr({"data-clone":"last","data-slide":0}).appendTo(s).show();d.attr({"data-clone":"first","data-slide":0}).prependTo(s).show();o=s.children("li");v.slidecount=o.length;h=e('<div class="bjqs-wrapper"></div>');if(r.responsive&&m.width<r.width){h.css({width:m.width,height:m.height,overflow:"hidden",position:"relative"});s.css({width:m.width*(v.slidecount+2),left:-m.width*v.currentslide})}else{h.css({width:r.width,height:r.height,overflow:"hidden",position:"relative"});s.css({width:r.width*(v.slidecount+2),left:-r.width*v.currentslide})}o.css({"float":"left",position:"relative",display:"list-item"});h.prependTo(i);s.appendTo(h)},x=function(){u=e('<ul class="bjqs-controls"></ul>');a=e('<li class="bjqs-next"><a href="#" data-direction="'+g.fwd+'">'+r.nexttext+"</a></li>");f=e('<li class="bjqs-prev"><a href="#" data-direction="'+g.prev+'">'+r.prevtext+"</a></li>");u.on("click","a",function(t){t.preventDefault();var n=e(this).attr("data-direction");if(!v.animating){n===g.fwd&&O(g.fwd,!1);n===g.prev&&O(g.prev,!1)}});f.appendTo(u);a.appendTo(u);u.appendTo(i);if(r.centercontrols){u.addClass("v-centered");var t=(i.height()-a.children("a").outerHeight())/2,n=t/r.height*100,s=n+"%";a.find("a").css("top",s);f.find("a").css("top",s)}},T=function(){l=e('<ol class="bjqs-markers"></ol>');e.each(o,function(t,n){var i=t+1,s=t+1;r.animtype==="slide"&&(s=t+2);var o=e('<li><a href="#">'+i+"</a></li>");i===v.currentslide&&o.addClass("active-marker");o.on("click","a",function(e){e.preventDefault();!v.animating&&v.currentslide!==s&&O(!1,s)});o.appendTo(l)});l.appendTo(i);c=l.find("li");if(r.centermarkers){l.addClass("h-centered");var t=(r.width-l.width())/2;l.css("left",t)}},N=function(){e(document).keyup(function(e){if(!v.paused){clearInterval(v.interval);v.paused=!0}if(!v.animating)if(e.keyCode===39){e.preventDefault();O(g.fwd,!1)}else if(e.keyCode===37){e.preventDefault();O(g.prev,!1)}if(v.paused&&r.automatic){v.interval=setInterval(function(){O(g.fwd)},r.animspeed);v.paused=!1}})},C=function(){i.hover(function(){if(!v.paused){clearInterval(v.interval);v.paused=!0}},function(){if(v.paused){v.interval=setInterval(function(){O(g.fwd,!1)},r.animspeed);v.paused=!1}})},k=function(){e.each(o,function(t,n){var r=e(n).children("img:first-child").attr("title");r||(r=e(n).children("a").find("img:first-child").attr("title"));if(r){r=e('<p class="bjqs-caption">'+r+"</p>");r.appendTo(e(n))}})},L=function(){var e=Math.floor(Math.random()*v.slidecount)+1;v.currentslide=e;v.currentindex=e-1},A=function(e){if(e===g.fwd)if(o.eq(v.currentindex).next().length){v.nextindex=v.currentindex+1;v.nextslide=v.currentslide+1}else{v.nextindex=0;v.nextslide=1}else if(o.eq(v.currentindex).prev().length){v.nextindex=v.currentindex-1;v.nextslide=v.currentslide-1}else{v.nextindex=v.slidecount-1;v.nextslide=v.slidecount}},O=function(e,t){if(!v.animating){v.animating=!0;if(t){v.nextslide=t;v.nextindex=t-1}else A(e);if(r.animtype==="fade"){if(r.showmarkers){c.removeClass("active-marker");c.eq(v.nextindex).addClass("active-marker")}o.eq(v.currentindex).fadeOut(r.animduration);o.eq(v.nextindex).fadeIn(r.animduration,function(){v.animating=!1;v.currentslide=v.nextslide;v.currentindex=v.nextindex})}if(r.animtype==="slide"){if(r.showmarkers){var n=v.nextindex-1;n===v.slidecount-2?n=0:n===-1&&(n=v.slidecount-3);c.removeClass("active-marker");c.eq(n).addClass("active-marker")}r.responsive&&m.width<r.width?v.slidewidth=m.width:v.slidewidth=r.width;s.animate({left:-v.nextindex*v.slidewidth},r.animduration,function(){v.currentslide=v.nextslide;v.currentindex=v.nextindex;if(o.eq(v.currentindex).attr("data-clone")==="last"){s.css({left:-v.slidewidth});v.currentslide=2;v.currentindex=1}else if(o.eq(v.currentindex).attr("data-clone")==="first"){s.css({left:-v.slidewidth*(v.slidecount-2)});v.currentslide=v.slidecount-1;v.currentindex=v.slidecount-2}v.animating=!1})}}};y()}})(jQuery);








$(document).ready(function() {
	$.SideBarMenuCtrl();
	$('#TopMenu').DropDownMenu();
	//$.SlideLogo();
	//$('#header .logo').hide();

        $('#banner-fade').bjqs({
			animtype : 'fade',
			usecaptions :false,
			showcontrols:false,
            height : 223,
            width : 860,
            responsive : true,
            randomstart : true
          });



});



var goToByScroll = function(id){
   $('html,body').animate({scrollTop: $("#"+id).offset().top},'slow');
}

var Redirection = function(go,time){
	if(time=='') location.href = go;
	else
	setTimeout(function(){
		location.href = go;
	},(time*1000));
};



var ErrorCallback = function(XMLHttpRequest, textStatus, errorThrown){
	//$('#message').removeClass().addClass('error').text('There was an error.'+errorThrown).show(500);
};

/*Plugin*/


/*http://phpjs.org*/
 function is_float (mixed_var) {
	return ( +mixed_var );
	//return +mixed_var === mixed_var && !!(mixed_var % 1);
 //return s.match(/[1-9]\d*(?:\.\d{0,2})?/) ? true : false;
 }
function is_numeric (mixed_var) {
	return (typeof(mixed_var) === 'number' || typeof(mixed_var) === 'string') && mixed_var !== '' && !isNaN(mixed_var);
}



   function Popup03(url){
	newWin=window.open(url,"Member","scrollbars=auto,resizable=0,width=260,height=242,top=100,left=100");
		if (newWin !=null) {
				newWin.opener=self;
		}
  }

   function mem_log(){
	newWin=window.open('member.php',"Member","scrollbars=auto,resizable=0,width=750,height=463,top=100,left=100");
		if (newWin !=null) {
				newWin.opener=self;
		}
  }

   function Popupthanked(url){
	newWin=window.open(url,"thanked","scrollbars=auto,resizable=0,width=330,height=160,top=100,left=100");
		if (newWin !=null) {
				newWin.opener=self;
		}
  }

	function POPUP(url, winName)
	{
		if ( ! winName ) winName = '';
		var newWin=window.open(url, winName,"width=650,height=610,left=200,top=100,resizable=yes,menubar=no,location=yes,status=yes,scrollbars=yes");
		if (newWin !=null) {
				newWin.opener=self;
		}
		 return ;
	}

